<template>
  <div class="callContainer">
    <div class="leaveMessage">
      <p>有需求，请给我留言吧</p>
      <div class="messageContent">
        <div class="box">
          <img src="@/assets/img/yonghuming.png" alt="">
          <input type="text" v-model="name" @input="inputHadler" placeholder="您的姓名">
        </div>
        <div class="box">
          <img src="@/assets/img/tel-fill.png" alt="">
          <input type="text" v-model="phone" @input="inputHadler" placeholder="您的电话（必填）">
        </div>
        <div class="liuyanbox">
          <img src="@/assets/img/qianyuejilu.png" alt="">
          <textarea name="" id="" v-model="liuyan" @input="inputHadler" placeholder="输入内容…"></textarea>
          <!--          <input type="text" v-model="company" @input="inputHadler">-->
        </div>
        <div class="notice">
          请写下您的需求，销售人员将为您服务
          我们会保障您的信息安全
        </div>
        <div class="btnContainer">
          <button type="button" class="submitDisBtn" @click="leaveFlag=false">取消</button>
          <button type="button" class="submitBtn" @click="liuyanHadle">提交</button>
        </div>

        <!--      :class="[submitFlag?'submitBtn':'submitDisBtn']"  -->
      </div>
    </div>
    <div class="callContent">
      <p class="title">联系销售人员</p>
      <p class="number">拨打电话：<a :href="'tel:'+showPhone">{{showPhone}}</a> </p>
    </div>
  </div>
</template>

<script>
import {Popup, Toast} from "vant";
import {post} from "@/assets/js/http";
export default {
name: "tel",
  data() {
    return {
      showPhone: "",
      liuyan:"",
      name:"",
      phone:"",
    }
  },
  components:{
    [Popup.name]:Popup
  },
  mounted() {
    this.showPhone = window.parent.phonenumber;
  },
  methods:{
    closePhone(){
      window.parent.closeupwin()
    },
    inputHadler(){
      if (this.company&&this.liuyan&&this.name&&this.phone){
        this.submitFlag = true;
      }else {
        this.submitFlag = false;
      }
    },
    liuyanHadle(){
      if (this.name===''){
        Toast('请输入用户名');
        return false;
      }else if (!/^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(this.phone)){
        Toast('请输入正确的手机号');
        return false;
      }else if (this.liuyan===''){
        Toast('请输入留言内容');
        return false;
      }
      let param = {
        "name":this.name,"phone":this.phone,"message":this.liuyan
      }
      post('https://3nsa42vmtxxsw.cfc-execute.gz.baidubce.com/addusermsg',param).then(res=>{
        console.log(res)
        Toast(res);
        this.leaveFlag=false
      }).catch(res=>{
        console.log(res)
      })
    },
  }
}
</script>

<style scoped lang="less">
.callContainer{
  width: 100%;
  background: #FFFFFF;
  margin: 0 auto;
  border-radius: 8px 8px 0px 0px;
.close{
  font-size: 15px;
  font-weight: 500;
  color: #666666;
  height: 44px;
  line-height: 44px;
}
}
.callContent{
  width: 335px;
  height: 98px;
  background: #FFFFFF;
  box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.09);
  border-radius: 10px;
  margin: 60px auto 0 auto;
  overflow: hidden;
  border-top: 2px solid #A4CFFB;
}
.callContainer .title{
  font-size: 17PX;
  color: #333333;
  margin-top: 30px;
}
.callContainer .number{
  font-size: 15px;
  color: #666666;
  border-bottom: 1px solid rgba(151, 151, 151, 0.08);
  margin-top: 8px;
a{
  color: #027AFF;
}
}
.leaveMessage{
  background-color: #FFFFFF;
}
.leaveMessage p{
  font-size: 15px;
  color: #333333;
  line-height: 23px;
  letter-spacing: 1px;
  margin-bottom: 20px;
  text-align: center;
  margin-top: 30px;

}
.message a{
  color: #027AFF;
}
.message video{
  width: 278px;
  height: 180px;
}
.messageContent {
  width: 335px;
  margin: 0 auto;
  background: #FFFFFF;
}
.submitBtn{
  width: 153px;
  height: 40px;
  border-radius: 2px;
  line-height: 40px;
  font-size: 15px;
  background-color: #027AFF;
  text-align: center;
  color: #FFFFFF;
  border: 1px solid #027AFF;
}
.submitDisBtn{
  width: 153px;
  height: 40px;
  line-height: 40px;
  font-size: 15px;
  background-color: #E5E5E5;
  border-radius: 2px;
  text-align: center;
  color: #868686;
  border: 1px solid #E5E5E5;
}
.btnContainer{
  width: 325px;
  margin: 0 auto;
  display: flex;flex-direction: row;
  justify-content: space-around;
}
.box{
  width: 315px;
  height: 48px;
  background: #FFFFFF;
  border-radius: 2px;
  border: 1px solid #027AFF;
  margin: 20px auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  padding-left: 10px;
  img{
    display: block;
    width: 24px;
    height: auto;
  }
  input{
    width: 100%;
    display: block;
    margin: 0 auto;
    height: 100%;
    border: none;
    padding-left: 10px;
  }
}
.liuyanbox{
  width: 315px;
  height: 140px;
  border-radius: 2px;
  border: 1px solid #027AFF;
  margin: 10px auto;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  padding-left: 10px;
  img{
    display: block;
    width: 24px;
    height: auto;
    margin-top: 10px;
  }
  textarea{
    width: 100%;
    display: block;
    margin: 0 auto;
    height: 100%;
    border: none;
    padding: 10px;
  }
}
.messageContent label{
  width: 60px;
  font-size: 15px;
  color: #999999;
  line-height: 23px;
  letter-spacing: 1px;
}
.messageContent label span{
  color: #E05353;
}
.notice{
  width: 236px;
  height: 36px;
  font-size: 13px;
  font-weight: 400;
  color: #9FC1E4;
  line-height: 18px;
  margin: 24px auto 20px auto;
}
.header{
  width: 375px;
  height: 60px;
  background: #027AFF;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  position: fixed;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  z-index: 10;
}
.header img{
  display: block;
  width: 36px;
  height: 36px;
  margin: 12px;
}
.header p{
  font-size: 17px;
  font-family: SourceHanSansCN-Regular, SourceHanSansCN;
  font-weight: 400;
  color: #FFFFFF;
  letter-spacing: 1px;
}
</style>